package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemDict;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 字典查询
 *
 * @author luwc
 * @title DictBO
 * @description
 * @time 2023/5/28 21:13
 * @version: 1.0
 */
@Data
public class DictBO extends AbstractPageQuery {
    private String name;
    private String marks;
    private String status;
    private String stime;
    private String etime;
    private String type;

    @Override
    public LambdaQueryWrapper<SystemDict> toQueryWrapper() {
        LambdaQueryWrapper<SystemDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if (StringUtils.isNotEmpty(name)) {
            lambdaQueryWrapper.like(SystemDict::getName, this.name);
        }
        if (StringUtils.isNotEmpty(marks)) {
            lambdaQueryWrapper.like(SystemDict::getMarks, this.marks);
        }
        if (StringUtils.isNotEmpty(status)) {
            lambdaQueryWrapper.eq(SystemDict::getStatus, status);
        }
        if (StringUtils.isNotEmpty(getType())) {
            lambdaQueryWrapper.eq(SystemDict::getType, getType());
        }
        if (StringUtils.isNotEmpty(stime)) {
            lambdaQueryWrapper.gt(SystemDict::getCreatedAt, stime);
        }
        if (StringUtils.isNotEmpty(etime)) {
            lambdaQueryWrapper.lt(SystemDict::getCreatedAt, etime);
        }
        return lambdaQueryWrapper;
    }
}
